package com.tau.egonetwork.linkedin;

import com.tau.egonetwork.net.IRequest;

public class LinkedinRequest {

	public static IRequest egoProfileRequest(final String access_token) {
		return new IRequest() {
			
			@Override
			public String generateRequestURL() {
				
				StringBuilder s = new StringBuilder();
				
				s.append("https://api.linkedin.com/v1/people/");
				s.append("~:(id,first-name,last-name,location:(name),");
				s.append("group-memberships,");
				s.append("connections:(id,first-name,last-name,location:(name)))/");
				s.append("?format=json");
				s.append("&oauth2_access_token=");
				s.append(access_token);
				
				return s.toString();
			}

		};
	}
	
	public static IRequest firstDegreeConnectionsRequests(String friendsIDs, String accessToken) {
		return firstDegreeConnectionsRequests(friendsIDs, accessToken, 0);
	}
	
	public static IRequest firstDegreeConnectionsRequests(final String friendsIDs, final String accessToken, final int start) {
		return new IRequest() {
			
			@Override
			public String generateRequestURL() {
				
				StringBuilder s = new StringBuilder();
				
				s.append("https://api.linkedin.com/v1/people::(");
				s.append(friendsIDs);
				s.append("):(id,first-name,last-name,relation-to-viewer)/");
				s.append("?format=json");
				
				if (start > 0) {
					s.append("&start=");
					s.append(start);
				}
				
				s.append("&oauth2_access_token=");
				s.append(accessToken);
								
				return s.toString();
				
			}
		};
	}
	
}
